var t = getApp(), a = 0, e = 0;

Page({
    data: {
        isSelf: !0,
        showTab: !1,
        is_open: "",
        review: "",
        release: "",
        activeName: "1",
        videoList: [],
        bannerList: [],
        newArray1: [],
        newArray2: [],
        showLoading: !1,
        member: {},
        isLoadMore: !1,
        page: 1,
        total_page: 0,
        activitys1: [],
        activitys2: [],
        imgCount: 0,
        noload: !1
    },
    onLoad: function(t) {
        this.getData(this.data.activeName), this.options.uid && this.setData({
            isSelf: !1
        });
    },
    handleClick: function(t) {
        this.setData({
            activeName: t.detail.name,
            page: 1
        }), this.getData(this.data.activeName);
    },
    toVideo: function(t) {
        var a = t.currentTarget.dataset.item, e = this.data.videoList.findIndex(function(t, e, i) {
            return t.id === a.id;
        });
        e = Math.ceil((e + 1) / 20), wx.navigateTo({
            url: "/packageC/video_goods/VideoDetail/VideoDetail?vid=" + a.id + "&page=" + e + "&status=" + this.data.activeName + "&uid=" + this.data.member.uid
        });
    },
    onImageLoad: function(t) {
        for (var i = t.currentTarget.id, o = t.detail.width, s = t.detail.height, n = this.data.videoList, d = null, r = o / s, c = 0; c < n.length; c++) if (n[c].id == i) {
            d = n[c];
            break;
        }
        this.data.imgCount += 1;
        var g = this.data.activitys1, u = this.data.activitys2;
        a <= e ? (a += 176 / r + 60, g.push(d)) : (e += 176 / r + 60, u.push(d));
        var l = {
            activitys1: g,
            activitys2: u
        };
        this.data.imgCount >= this.data.videoList.length && this.setData({
            showLoading: !0
        }), this.setData(l);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) wx.showToast({
            title: "没有更多了",
            icon: "none",
            duration: 1e3
        }); else {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), console.log(this.data.activeName), console.log(this.data.page), this.getMoreData(this.data.activeName);
        }
    },
    onShareAppMessage: function() {},
    getData: function(i) {
        var o = this, s = this, n = t.getNetAddresss("plugin.video-share.frontend.video.my-video");
        t._getNetWork({
            url: n,
            data: {
                v_uid: this.options.uid || "",
                page: s.data.page,
                status: i
            },
            success: function(t) {
                var i = t.data;
                1 == i.result ? (s.setData({
                    is_open: !o.options.uid && i.data.is_open,
                    member: i.data.member,
                    review: i.data.review,
                    release: i.data.release,
                    current_page: i.data.video.current_page,
                    last_page: i.data.video.last_page,
                    showLoading: !0
                }), s.setData({
                    activitys1: [],
                    activitys2: []
                }), a = 0, e = 0, s.setData({
                    videoList: i.data.video.data
                })) : wx.showToast({
                    title: i.msg,
                    icon: "none",
                    duration: 1500
                }), s.setData({
                    showTab: !0
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    delTap: function(a) {
        console.log(a.currentTarget.dataset.info.id);
        var e = a.currentTarget.dataset.info.id, i = this, o = t.getNetAddresss("plugin.video-share.frontend.video.del");
        t._getNetWork({
            url: o,
            data: {
                id: e
            },
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    var o = getCurrentPages(), s = o[o.length - 2].data.videoList;
                    console.log(s), s.forEach(function(t, a) {
                        t.id == e && s.splice(a, 1);
                    }), o[o.length - 2].setData({
                        videoList: s,
                        activitys1: [],
                        activitys2: []
                    }), i.setData({
                        noload: !1
                    }), wx.showToast({
                        title: a.msg,
                        icon: "none",
                        duration: 1e3,
                        success: function() {
                            i.getData(i.data.activeName);
                        }
                    });
                } else wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function(a) {
        var e = this, i = t.getNetAddresss("plugin.video-share.frontend.video.my-video");
        t._getNetWork({
            url: i,
            data: {
                v_uid: this.options.uid || "",
                page: e.data.page,
                status: a
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    is_open: a.data.is_open,
                    member: a.data.member,
                    review: a.data.review,
                    release: a.data.release,
                    current_page: a.data.video.current_page,
                    last_page: a.data.video.last_page,
                    showLoading: !0
                }), e.setData({
                    videoList: e.data.videoList.concat(a.data.video.data)
                })) : wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});